package com.gill.servlet;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 功能：访问hello，将请求转发到hello.jsp上
 */

/**
 * 当编写MVC模块的使用需要注释该注解，否则会抛出以下错误
 * 名为 [com.gill.servlet.HelloServlet]和 [org.sampleSpringFramework.mvc.DispatcherServlet] 的servlet不能映射为一个url模式(url-pattern) [/]
 */
//@WebServlet("/")
@Slf4j//自动创建log
public class HelloServlet extends HttpServlet {

	@Override
	public void init() throws ServletException {
		System.out.println("测试：首次请求，请求在被处理前执行，之后不会再执行");
	}

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		log.info("请求路径："+req.getServletPath());
		log.info("请求方式："+req.getMethod());
		log.info("==========================");
	}
}
